﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage<IList<Prodma.DataAccess.Models.ViewModels.ContentVm>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=System.Configuration.ConfigurationManager.AppSettings["pageTitle"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div class="listHeader">
        <img src="../../Images/ListImages/contentlist.png" alt="" class="listHeaderIco" />
        <div class="listHeaderText">Yazı Yöneticisi</div>
        
        <div class="listHeaderMenuBox">
            <% Html.RenderPartial("/views/shared/userControls/navigation.ascx",
                   Prodma.DataAccess.Authorization.Authorization.GetNavigation("content", 11));%>
        </div>
    </div>
    
    <div class="listFindBar">
        <% Html.RenderPartial("/views/shared/userControls/find.ascx",
               new Prodma.DataAccess.Models.UserControlViewModels.FindVm() { View = "content", Keys = new List<string>() { "categoryId", "page" }, Values = new List<string>() { Request.QueryString["categoryId"], "0" } }); %>
        
        <% Html.RenderPartial("/views/shared/userControls/archiveSelector.ascx", ViewData["selectedList"], new ViewDataDictionary()); %>
    </div>
    
    <div class="listTitleContainer">
        <div class="listTitleCenter-50">#</div>
        <div class="listTitleCenter-50"><input type="checkbox" id="chk" name="chk" /></div>
        <div class="listTitleLeft-400">Ad</div>
        <div class="listTitleCenter-150">Sıra</div>
        <div class="listTitleCenter-150">Kategori</div>
        <div class="listTitleCenter-150">Dil</div>
        <div class="listTitleCenter-150">Durum</div>
        <div class="listTitleCenter-50">ID</div>
    </div>
    
    <div class="listRowContainer">
    <% int totalCount = Convert.ToInt32(ViewData["TotalRowCount"]); %>
    <!-- Kategorilere göre ayrıştırma -->
    <% List<int> contentCounts = (List<int>)ViewData["contentCounts"]; %>
    <!-- Listeleme -->
    <% int counter = 1; %>
    <% int seperatorCounter = 0; %>
    
    <% foreach (int category in (IList<int>)ViewData["categoryList"]) %>
    <% { %>
         <% int same = 0; %>    
         <% foreach (Prodma.DataAccess.Models.ViewModels.ContentVm content in ViewData.Model) %>
         <% { %>
              <% if(Convert.ToInt32(category) == content.Category.Id) %>
              <% { %>
                   <% same++; %>
                   <% if (counter % 2 != 0) %>
                   <% { %>
                    <div class="listRow1">
                      <div class="listColumnCenter-50"><%=counter %></div>
                      <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=content.Id %>' name="chkSelect" /></div>
                      <div class="listColumnLeft-400">
                        <a href='/content/edit/?id=<%=content.Id %>&page=<%=Request.QueryString["page"]%>' class="listSelectItemBold">
                            <%=content.Name%>
                        </a>
                      </div>
                      <div class="listColumnCenter-150">
                        <% if (content.Order.OrderNo != contentCounts[seperatorCounter]) %>
                        <% { %>
                               <a href='/content/orderUp/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>'><img src="../../Images/ListImages/orderup.png" border="0" alt="" /></a>
                        <% } %>
                        <% else %>
                        <% { %>
                               <img src="../../Images/ListImages/blankorder.png" alt="" />
                        <% } %>
                        <% if (content.Order.OrderNo != 1) %>
                        <% { %>
                               <a href='/content/orderDown/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>'><img src="../../Images/ListImages/orderdown.png" border="0" alt="" /></a>
                        <% } %>
                        <% else %>
                        <% { %>
                               <img src="../../Images/ListImages/blankorder.png" alt="" />
                        <% } %>                                
                        <input type="text" id='order<%=counter %>' name="order" value='<%=(contentCounts[seperatorCounter] + 1) - content.Order.OrderNo %>' class="listOrderInput" maxlength="5"  />
                        <a href="#" id='aSetOrder<%=counter %>' onclick='setOrder(<%=counter %>)' ><img src="../../Images/ListImages/orderok.png" border="0" alt="" /></a>
                        <input type="hidden" id='hdnSetOrder<%=counter %>' value='/content/setOrder/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>' />
                      </div>
                      <div class="listColumnCenter-150"><%=content.Category.Name %></div>
                      <div class="listColumnCenter-150"><%=content.Language.Name %></div>
                      <div class="listColumnCenter-150"><%=content.State.Name %></div>
                      <div class="listColumnCenter-50"><%=content.Id %></div>
                    </div>
                  <% } %>
                  <% else %>
                  <% { %>
                  <div class="listRow2">
                      <div class="listColumnCenter-50"><%=counter %></div>
                      <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=content.Id %>' name="chkSelect" /></div>
                      <div class="listColumnLeft-400">
                        <a href='/content/edit/?id=<%=content.Id %>&page=<%=Request.QueryString["page"]%>' class="listSelectItemBold">
                            <%=content.Name%>
                        </a>
                      </div>
                      <div class="listColumnCenter-150">
                        <% if (content.Order.OrderNo != contentCounts[seperatorCounter]) %>
                        <% { %>
                               <a href='/content/orderUp/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>'><img src="../../Images/ListImages/orderup.png" border="0" alt="" /></a>
                        <% } %>
                        <% else %>
                        <% { %>
                               <img src="../../Images/ListImages/blankorder.png" alt="" />
                        <% } %>
                        <% if (content.Order.OrderNo != 1) %>
                        <% { %>
                               <a href='/content/orderDown/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>'><img src="../../Images/ListImages/orderdown.png" border="0" alt="" /></a>
                        <% } %>
                        <% else %>
                        <% { %>
                               <img src="../../Images/ListImages/blankorder.png" alt="" />
                        <% } %>                                
                        <input type="text" id='order<%=counter %>' name="order" value='<%=(contentCounts[seperatorCounter] + 1) - content.Order.OrderNo %>' class="listOrderInput" maxlength="5"  />
                        <a href="#" id='aSetOrder<%=counter %>' onclick='setOrder(<%=counter %>)' ><img src="../../Images/ListImages/orderok.png" border="0" alt="" /></a>
                        <input type="hidden" id='hdnSetOrder<%=counter %>' value='/content/setOrder/?id=<%=content.Id %>&orderNo=<%=content.Order.OrderNo %>&category=<%=content.Category.Id %>&archive=<%=content.Archive.Id %>&page=<%=Request.QueryString["page"] %>' />
                      </div>
                      <div class="listColumnCenter-150"><%=content.Category.Name %></div>
                      <div class="listColumnCenter-150"><%=content.Language.Name %></div>
                      <div class="listColumnCenter-150"><%=content.State.Name %></div>
                      <div class="listColumnCenter-50"><%=content.Id %></div>
                  </div>
                  <% } %>
                  <% counter++; %>
              <% } // if Category == Content.Category.Id %>
         <% } // ForEach Content %>
         <% seperatorCounter++; %>
    <% } // ForEach Category %>
    </div>
    
    <div class="listFooter">
        <div class="listFooterData">Toplam Kayıt Sayısı : <%=ViewData["TotalRowCount"] %></div>
    </div>
    
    <div class="pagerContainer">
       <% Html.RenderPartial("/views/shared/userControls/dataPager.ascx", new Prodma.DataAccess.Models.UserControlViewModels.DataPagerVm()
       {
           View = "content",
           TotalRowCount = Convert.ToInt32(ViewData["TotalRowCount"]),
           Keys = new List<string>() { "categoryId", "page" },
           Values = new List<string>() { Request.QueryString["categoryId"], "0" }
       }, new ViewDataDictionary()); %>
    </div>

    <script type="text/javascript">
        $(function() {
            $('#chk').click(function() {
                $("input[type='checkbox']").attr('checked', $('#chk').is(':checked'));
            });
        });

        function setOrder(counter) {
            var newOrderNo = $('#order' + counter).val();
            if (newOrderNo == '' || newOrderNo <= 0) {
                alert('Yeni sıra numarası pozitif bir sayı olmalıdır !');
                $('#order' + counter).focus();
                return false;
            }
            else {
                var txtOrderNo = $('#order' + counter).val();
                window.location.replace($('#hdnSetOrder' + counter).val() + "&setOrderNo=" + $('#order' + counter).val());
            }
        }
    </script>

</asp:Content>
